@extends('layouts.master')
@section('title')
    列表
@endsection
@section('content')
    <div class="row">
        <div class="col-lg-12">
            <div class="ibox ">
                <div class="ibox-content">
                    @section('toolbar')
                        <span class="left">
                             {{$title}}
                        </span>
                    @endsection
                    @include('common.toolbar', ['pager' => $list])
                    <table class="layui-table">
                        <thead>
                        <tr>
                            <th>ID</th>
                            <th>昵称</th>
                            <th>真实姓名</th>
                            <th>证件信息</th>
                            <th>显示</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        @foreach($list as $index => $item)
                            <tr>
                                <th>{{$item->id}}</th>
                                <td>
                                    id:{{$item->user->id}}<br/>
                                    {{$item->user->nickname}}
                                </td>
                                <th>{{$item->realname}}<br/>{{$item->phone}}</th>
                                <td> <a style= 'color:#0072bc; text-decoration : underline' onclick="show_license({{$index}})" >点击查看</a>
                                    <ul id="{{'license'.$index}}" style="display: none">
                                        <li><img src="{{$item->material['cartImgPros']}}" alt="身份证正面"></li>
                                        <li><img src="{{$item->material['cartImgCons']}}" alt="身份证反面"></li>
                                    </ul>
                                </td>
                                <th>
                                    {{$item->status_text}}
                                </th>
                                <th>
                                    <div class="dropdown btn btn-info" >
                                        <div data-toggle="dropdown" class="dropdown-toggle" href="#">
                                            操作
                                        </div>
                                        <ul class="dropdown-menu animated fadeInRight m-t-xs">

                                            <li>
                                                <a class="dropdown-item load_iframe" href="javascript:;" data-url="{{route('escort.add',['id'=>$item->id])}}"
                                                   data-width="800px" data-height="500px">
                                                    查看
                                                </a>
                                                @if($item->status == 0)
                                                    <a class="btn btn-outline btn-success ajax-confirm" data-url="{{route('escort.change',['id'=>$item->id, 'status' => 1])}}" data-title="确定吗？" href="javascript:;">审核通过</a>
                                                    <a class="btn btn-outline btn-success ajax-confirm" data-url="{{route('escort.change',['id'=>$item->id, 'status' => -1])}}" data-title="确定吗？" href="javascript:;">驳回</a>
                                                @elseif($item->status == 1)
                                                    <a class="btn btn-outline btn-success ajax-confirm" data-url="{{route('escort.change',['id'=>$item->id, 'status' => 2])}}" data-title="确定吗？" href="javascript:;">休息</a>
                                                @elseif($item->status == 2)
                                                    <a class="btn btn-outline btn-success ajax-confirm" data-url="{{route('escort.change',['id'=>$item->id, 'status' => 1])}}" data-title="确定吗？" href="javascript:;">开工</a>
                                                @endif
                                                <a class="btn btn-danger ajax-confirm delete"
                                                   data-url="{{route('escort.destroy',['id'=>$item->id])}}" data-title="确定要删除该记录吗？" href="javascript:;">删除</a>
                                            </li>

                                        </ul>
                                    </div>
                                </th>
                            </tr>
                        @endforeach
                        </tbody>
                    </table>
                    @include('common.pagination', ['pager' => $list])
                </div>
            </div>
        </div>
    </div>
@endsection
@section('script')
    <script>
        function show_license(index){
            var viewer = new Viewer(document.getElementById('license'+index),{
                hidden: function () {
                    viewer.destroy();
                },
            });
            viewer.show()
        }
    </script>
@endsection